package com.orange.test;

import com.orange.demo.ParserManager;
import com.orange.demo.Song;

/**
 * @author HongHao
 * @since 2021-08-30 22:24
 */
public class App {

    public static void main(String[] args) {
        // testMp3Parser();
        testMp4Parser();
    }

    public static void testMp3Parser() {
        //  ParserManager.getSong() 是静态方法，所以会先初始化 ParserManager 类
        Song song = ParserManager.getSong(mockSongData("MP3"));
        System.out.println("------------------------");
        System.out.println("Name:" + song.getName());
        System.out.println("Author:" + song.getAuthor());
        System.out.println("Time:" + song.getTime());
        System.out.println("Format:" + song.getFormat());
    }

    public static void testMp4Parser() {
        Song song = ParserManager.getSong(mockSongData("MP4"));
        System.out.println("------------------------");
        System.out.println("Name:" + song.getName());
        System.out.println("Author:" + song.getAuthor());
        System.out.println("Time:" + song.getTime());
        System.out.println("Format:" + song.getFormat());
    }

    /**
     * mock歌曲数据
     *
     * @param formatType
     * @return
     */
    private static byte[] mockSongData(String formatType) {
        return formatType.getBytes();
    }

}
